package week_10.实验3_查找和排序.cn.edu.besti.cs1723.LXY2328;

import junit.framework.TestCase;
import org.junit.Test;

import java.util.Arrays;

public class SortingTest_4 extends TestCase {
    @Test
    public void testSortingSearch1() throws Exception {
        Comparable array1[] = {20, 17, 23, 28, 69, 97,33, 22, 11};//正常
        System.out.println("原数组为：");
        for(int a = 0;a<array1.length;a++) {
            System.out.print(array1[a]+" ");
        }
        System.out.println();
        System.out.println("选择排序后的数组为：");
        System.out.println(Sorting.selectionSort(array1));
        System.out.println("插入排序后的数组为：");
        Sorting.insertionSort(array1);
        for(int a = 0;a<array1.length;a++) {
            System.out.print(array1[a]+" ");
        }
        System.out.println();
        System.out.println("归并排序后的数组为：");
        Sorting.mergeSort(array1);
        for(int a = 0;a<array1.length;a++) {
            System.out.print(array1[a]+" ");
        }
        Comparable array2[] = {20, 17, 23, 28, 69, 97,33, 22, 11};
        System.out.println();
        System.out.println("快速排序后的数组为：");
        Sorting.quickSort(array2);
        for(int a = 0;a<array2.length;a++) {
            System.out.print(array2[a]+" ");
        }
        System.out.println();
    }
    @Test
    public void testSortingSearch2() throws Exception {
        int array2[] = {20, 17, 23, 28, 69, 97,33, 22, 11};
        System.out.println("原数组为：");
        for(int a = 0;a<array2.length;a++) {
            System.out.print(array2[a]+" ");
        }
        System.out.println();
        System.out.println("冒泡排序后的数组为：");
        Sorting.bubbleSort(array2);
        for(int a = 0;a<array2.length;a++) {
            System.out.print(array2[a]+" ");
        }
        System.out.println();
        System.out.println("希尔排序后的数组为：");
        Sorting.ShellSort(array2);
        for(int a = 0;a<array2.length;a++) {
            System.out.print(array2[a]+" ");
        }
        System.out.println();
        System.out.println("堆排序后的数组为：");
        Sorting.HeapSort(array2);
        for(int a = 0;a<array2.length;a++) {
            System.out.print(array2[a]+" ");
        }
        System.out.println();

    }
    @Test
    public void testSortingSearch3() throws Exception {
        int array3[] = {20, 17, 23, 28, 69, 97,33, 22, 11, Integer.parseInt(null)};
        Sorting.HeapSort(array3);

    }
    @Test
    public void testSortingSearch5() throws Exception{
        Comparable[] array5 = {20172328,99999999};
        Sorting.quickSort(array5);
        assertEquals("[20172328, 99999999]", Arrays.toString(array5));

    }
}